package com.shop.cereshop.business.controller.write;

import com.shop.cereshop.business.service.write.CereWriteOffRecordService;
import com.shop.cereshop.business.utils.ContextUtil;
import com.shop.cereshop.commons.domain.write.CereWriteOffRecord;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lx
 */
@RestController
@RequestMapping("writeOff/record")
@Api(value = "核销记录", tags = "核销记录")
public class WriteOffRecordController {

  @Autowired
  private CereWriteOffRecordService cereWriteOffRecordService;

  // 您可以在这里添加接口方法

  @GetMapping("list")
  @ApiOperation(value = "获取核销记录列表")
  public Result<List<CereWriteOffRecord>> getWriteOffRecordList(@RequestParam(value = "page") @ApiParam(value = "页码", required = true) Integer page,
                                                                @RequestParam(value = "pageSize") @ApiParam(value = "每页数量", required = true) Integer pageSize) throws CoBusinessException {
    Long shopId = ContextUtil.getShopId();
    return Result.success(cereWriteOffRecordService.getWriteOffRecordList(shopId, page, pageSize));
  }

  @GetMapping("detail")
  @ApiOperation(value = "获取核销记录详情")
  public Result<CereWriteOffRecord> getWriteOffRecordDetail(@RequestParam(value = "record_id") @ApiParam(value = "核销记录ID", required = true) Long recordId) {
    return Result.success(cereWriteOffRecordService.getWriteOffRecordDetail(recordId));
  }
}